package com.company.ThreadLearn;


import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class ThreadTest {
    public ThreadTest() throws InterruptedException {
//        ThreadTest tt = new ThreadTest();
//        System.out.println("Main start");
//        threadStatus();
//        this.threadStop();
        ThreadProtect2 tp = new ThreadProtect2();
//        转为守护线程
        tp.setDaemon(true);
        tp.start();
        Thread.sleep(5000);
        System.out.println("Main end");
    }
    public void threadStatus() throws InterruptedException {
        ThreadClass th = new ThreadClass("Ldq");
        th.start();
        th.join();
        for(int i=0;i<3;i++){
            System.out.println("Main!");
        }
    }
    public void threadStop() throws InterruptedException{
        ThreadClass tc = new ThreadClass("link");
        tc.start();
        Thread.sleep(1000);
        tc.running = false;
        System.out.println("Main end");
    }
}
